import axios from 'axios'
/**
 * http请求
 */
// 设置默认响应时间
axios.defaults.timeout = 31 * 1000
const domains = {
  nCoV: 'http://rap2api.taobao.org/app/mock/232272',
  nosugartech: 'http://2019ncov.nosugartech.com'
}

export default class Http {
  static headers = {
    'Content-Type': 'application/json'
  }

  static async get(url, params = null, headers = this.headers, domain = 'nCoV') {
    const {
      data
    } = await axios.get(domains[domain] + url, {
      params,
      headers
    })
    return data
  }

  static async post(url, params = null, headers = this.headers, domain = 'nCoV') {
    const {
      data
    } = await axios.post(domains[domain] + url, params, {
      headers
    })
    return data
  }
}
